Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M3-107 만보기 인터페이스 구현 (ANDROID) #7

Merged
merged 16 commits into from
Jul 7, 2024

Conversation

tkdals802
Copy link
Contributor

@tkdals802 tkdals802 commented Jun 22, 2024

작업 내용*

  • 걸음수를 일정 기간 동안 초기화 시키도록 구현

고민한 내용*

  • Pedometer패키지에서 사용하는 Stream에서 전체 걸음수를 받고
    현재 걸음수 = 전체 걸음수 - 과거 걸음수 그리고 초기화 시킬 때마다
    과거 걸음수 = 전체 걸음수로 업데이트 시켜주는 과정으로 해결하였다.

    그리고 우선 map_screen의 '지도'text 아래에 걸음수가 나오도록 해놓았다.

  • 기술적 고민
    timer로 매 주기마다 계속해서 초기화 시켜 주는것
    Pedometer클래스를 직접 불러와서 걸음수를 가져올 수 없었다.

구현 방안

백그라운드 실행

걸음수를 항상 측정하려면 백그라운드로 항상 동작을 해야한다. 안드로이드에서 동작 시키려면 알림센터의 위젯으로 남겨두고 작업을 실행해야한다. 이것을 구현하기 위해 flutter_foreground_task 를 사용하였다.

  • flutter_foreground_task 와 메인 앱이 별도의 공간에 돌아간다. 따라서 같은 코드를 공유해도 서로 다른 메모리 상에서 구동되어 동기화가 어려웠다. 그래서 걸음수를 측정하는 로직을 flutter_foreground_task 에서만 돌리고 메인 앱에서 걸음수는 flutter_foreground_task 에서 측정되는 것을 가져오기만 하여 보여주는 역할만 하게 된다.
  • 걸음수를 초기화 하는 로직도 flutter_foreground_task 에서 실행되게 된다.

걸음수 측정

  • 안드로이드에서 걸음수를 측정하기 위해 pedometer 를 사용했다.
  • pedometer 는 기기가 켜진 순간부터 현재 까지의 걸음수를 반환한다. 따라서 일일 걸음수를 구하려면 자체적인 로직이 필요하다.
  • 그래서 getStorage 를 사용해서 걸음수를 스토리지에 지속적으로 저장하여 걸음수를 측정하게 했다.

리뷰 요구사항

  • 변수, 함수 이름
  • 클래스 구조

스크린샷

@tkdals802 tkdals802 added the enhancement New feature or request label Jun 22, 2024
return Column(
children: [
Text('지도'),
Obx(() => Text('${AndroidStepController.steps.value}'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지도 화면에 걸음수가 들어가서 conflict 날 수도 있을 것 같아요!!

// if(check==false){
// _pastSteps.value = event.steps;
// print('check ok');
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석은 빼고 커밋하는게 좋을거같네요~

Text('지도'),
],
);
final AndroidStepCounter AndroidStepController =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지도가 이미 작업되어있어서 이번 이슈에서는 하면에 표시하는 것은 안해도 될거같네요..


import '../utils/walking_service.dart';

class AndroidStepCounter extends GetxController implements WalkingService{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파일이름과 클래스 이름이 다르네여~

import '../utils/walking_service.dart';

class AndroidStepCounter extends GetxController implements WalkingService{
late Stream<StepCount> _stepCountStream;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service 에서 GetX 컨트롤러를 쓰는 거 보다 controller 에서 쓰는게 좋을거 같습니다.


int getCurrentStep();
void getCurrentStep(StepCount event);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인터페이스가 제 pr 에서도 바꿔서 충돌 날거 같네요

}

@override
void getCurrentStep(StepCount event){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event를 listen하며 currentStep 멤버변수를 증가시키는 함수를 따로 만들고
getCurrentStep()은 해당 멤버변수를 리턴만 하게끔 하면 어떨까요?

@tkdals802 tkdals802 force-pushed the feature/M3-107-android_walk_interface branch from 65c5938 to be1ab12 Compare July 3, 2024 08:09
@koomin1227 koomin1227 force-pushed the feature/M3-107-android_walk_interface branch from 087bbc0 to f94ef34 Compare July 6, 2024 15:13
@koomin1227 koomin1227 changed the title M3-107 Feat : 안드로이드 걷기 일정 주기 초기화 기능 구현 M3-107 만보기 인터페이스 구현 (ANDROID) Jul 7, 2024
@koomin1227 koomin1227 self-requested a review July 7, 2024 11:22
@tkdals802 tkdals802 merged commit e52c0d6 into develop Jul 7, 2024
1 check passed
@tkdals802 tkdals802 deleted the feature/M3-107-android_walk_interface branch July 7, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants